package com.junxonline.plat.service.base.impl;

import com.junxonline.plat.dao.model.User;
import com.junxonline.plat.dao.repository.UserRepository;
import com.junxonline.common.exception.CommonBizException;
import com.junxonline.common.util.CommonUtils;
import com.junxonline.plat.service.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BaseServiceImpl implements BaseService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public User getUser(Long userId) {

        User user = userRepository.findByUserId(userId);

        if (CommonUtils.isEmpty(user)) {
            throw CommonBizException.LOGIN_AUTH_IS_ERROR;
        }

        return user;
    }
}
